package com.example.redis.jedisCluster;

import org.springframework.beans.factory.annotation.Autowired;
import redis.clients.jedis.JedisCluster;

import java.util.List;


public class Consumer extends Thread {
    @Autowired
    private JedisCluster redisCluster;

    @Override
    public void run() {
        while (true) {
            //阻塞式brpop，List中无数据时阻塞，参数0表示一直阻塞下去，直到List出现数据
            List<String> listingList = redisCluster.brpop(0, "listingList");
            System.out.println(String.format("线程取数据：%s", listingList.get(1)));
        }
    }

    public static void main(String[] args) {
        Consumer redisConsumer = new Consumer();
        redisConsumer.start();
    }
}
